package code

import "inspector/pkg/errors"

// Common or Generic errors
func NewErrInternalServer() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100001,
		HTTPCode: 500,
		Message:  "err_internal_server",
		Expose:   true,
		Severity: "high",
	}
}

func NewErrNotFound() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100002,
		HTTPCode: 404,
		Message:  "err_not_found",
		Expose:   true,
		Severity: "medium",
	}
}

func NewErrBadRequest() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100003,
		HTTPCode: 400,
		Message:  "err_bad_request",
		Expose:   true,
		Severity: "low",
	}
}

func NewErrValidation() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100004,
		HTTPCode: 400,
		Message:  "err_validation",
		Expose:   true,
		Severity: "low",
	}
}

func NewErrUnauthorized() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100005,
		HTTPCode: 401,
		Message:  "err_unauthorized",
		Expose:   true,
		Severity: "medium",
	}
}

func NewErrForbidden() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100006,
		HTTPCode: 403,
		Message:  "err_forbidden",
		Expose:   true,
		Severity: "medium",
	}
}

func NewErrPageNotFound() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100007,
		HTTPCode: 404,
		Message:  "err_page_not_found",
		Expose:   true,
		Severity: "medium",
	}
}

// Auth related errors
func NewErrInvalidAuthHeader() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100101,
		HTTPCode: 401,
		Message:  "err_invalid_auth_header",
		Expose:   true,
		Severity: "low",
	}
}

func NewErrMissingHeader() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100102,
		HTTPCode: 401,
		Message:  "err_missing_header",
		Expose:   true,
		Severity: "medium",
	}
}

func NewPermissionDenied() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100103,
		HTTPCode: 403,
		Message:  "permission_denied",
		Expose:   true,
		Severity: "medium",
	}
}

// Database related errors
func NewErrDBConnectionFailed() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100201,
		HTTPCode: 500,
		Message:  "err_db_connection_failed",
		Expose:   false,
		Severity: "high",
	}
}

func NewErrDBQueryFailed() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100202,
		HTTPCode: 500,
		Message:  "err_db_query_failed",
		Expose:   false,
		Severity: "high",
	}
}

func NewErrCiphertextMistake() *errors.ErrorCode {
	return &errors.ErrorCode{
		Code:     100301,
		HTTPCode: 500,
		Message:  "err_cipher_text_mistake",
		Expose:   false,
		Severity: "low",
	}
}
